<?php

/**
 * xdq
 */
class Action
{

    private $per_page = 7;


    private $userinfo = array();

    public function index() {

        exit(':p');

        $module_path = '/module/cinema_h5';

        Response::assign('module_path', $module_path);
        if (isset($_SESSION['user_id']) && isset($_SESSION['user_name']) ) {


            $day_pick = date("Y-m-d");//当天日期
            Response::assign('day_pick', $day_pick);


            //sign_user_id
            $total = _model('store')->getTotal(array('sign_user_id' => $_SESSION['user_id']));

            // 拼装搜索条件
            //当日新增门店数
            $filter_day = array(
                'sign_user_id' => $_SESSION['user_id'],
                '`sign_time` LIKE' => date("Y-m-d").'%' ,
               // '`status`  >=' => 1,
            );
            $add_day = _model('store')->getTotal($filter_day);
            if (!$add_day) {
                $add_day = 0;
            }

            //当月新增门店数
            $filter_month = array(
                'sign_user_id' => $_SESSION['user_id'],
                '`sign_time` >=' => date("Y-m-01"),
              //  '`status` >=' => 1,
            );
            $add_month = _model('store')->getTotal($filter_month);
            if (!$add_month) {
                $add_month = 0;
            }


            $season = ceil((date('n')) / 3);//当月是第几季度
            $date = date('Y-m-01', mktime(0, 0, 0, $season * 3 - 3 + 1, 1, date('Y')));

            //当季度新增门店数
            $filter_season = array(
                'sign_user_id' => $_SESSION['user_id'],
                '`sign_time` >=' => $date,
              //  '`status`  >=' => 1,
            );
            $add_season = _model('store')->getTotal($filter_season);
            if (!$add_season) {
                $add_season = 0;
            }

           // var_dump($filter_season);

            //当日订单数量和总金额 要与day接口的同步
            $filter_day = array(
                'marketing_id' => $_SESSION['user_id'],
                'receiver_time LIKE' => $day_pick.'%',
                '`status`' => 1
            );
            $output['amount'] = _model('order')->getTotal($filter_day);
            if (!$output['amount']) {
                $output['amount'] = 0;
            }

            $output['money'] = _model('order')->getFields('price', $filter_day);
            if ($output['money']) {
                $output['money'] = array_sum($output['money']);
            } else {
                $output['money'] = 0;
            }
            //var_dump($output); exit;


            Response::assign('output', $output);
            Response::assign('user_name',  $_SESSION['user_name'] );

            Response::assign('total', $total);
            Response::assign('add_day', $add_day);
            Response::assign('add_month', $add_month);
            Response::assign('add_season', $add_season);
            Response::display('output.html');
        } else {
            Response::display('login.html');
        }
    }

    public function logout() {
        if (isset($_SESSION['user_id'])) {
            unset($_SESSION['user_id']);
            unset($_SESSION['user_name']);
        }
        Response::redirect('/cinema_h5');
    }

    public function login() {
        $username = Request::Post('username', 0);     //手机号
        $password = Request::Post('password', 0);     //密码

        // 验证手机号
        if (!(user_helper::is_mobile($username))) {
            return_data(1, 'failed');
        }

         //通过手机号查询到密码
        $user_info1 = _model('user')->getList(array('mobile' => $username));
        if (empty($user_info1)) {
            return_data(1, '此手机号没查到密码');
            return 0;
        }
        else{
            $user_info1 = $user_info1[0];
        }

        $encrypt_passwd = md5(md5($password) . $user_info1['hash']);

        // 新系统的密码，md5
        if (strlen($user_info1['password']) == 32 && $encrypt_passwd == $user_info1['password']) {
            $userinfo = user_helper::get_user_info( $user_info1['id']);
        }
        else{

            $fail_info = array(
                1 =>strlen($user_info1['password']),
                2 =>$password,
                3 =>$user_info1['hash'],
                4 =>$user_info1['password'],
            );
            return_data(1,$fail_info);
        }

        //判断影院市场专员
        $userinfo = user_helper::get_user_info( $user_info1['id']);

        if (!(user_config::CINEMA_ASSISTANT == $userinfo['role_type'])) {
            return_data(3, 'failed');
        }


        //没有用_url缓存的，_model现查的
        $_SESSION['user_id'] = $user_info1['id'];
        $_SESSION['user_name'] = $user_info1['realname'];
        return_data(0, 'success');

    }


    public function day() {

        $date = Request::getParam('date', '');


        //日期格式转化  2016-8-1 ->  2016-08-01
        $var=explode("-",$date);

        if(strlen($var[1]) == 1){
            $var[1] = '0'.$var[1];
        }
        if(strlen($var[2]) == 1){
            $var[2] = '0'.$var[2];
        }

        $date = implode("-",$var);

        //var_dump($date);exit;

        $_SESSION['day_pick'] = $date;  //设置选择日期的session，为了返回用

        $module_path = '/module/cinema_h5';


        Response::assign('module_path', $module_path);
        Response::assign('success', 0);

        if (!isset($_SESSION['user_id'])) {
            Response::redirect('cinema_h5');
            return false;
        }


        //当日
        $filter_day = array(
            'marketing_id' => $_SESSION['user_id'],
            '`receiver_time` LIKE' => $date.'%' ,
            'status' => 1
        );

        //var_dump($filter_day); exit;
        $output['amount'] = _model('order')->getTotal($filter_day);
        if (!$output['amount']) {
            $output['amount'] = 0;
        }

        $output['money'] = _model('order')->getFields('price', $filter_day);
        if ($output['money']) {
            $output['money'] = array_sum($output['money']);
        } else {
            $output['money'] = 0;
        }

        echo json_encode($output);

    }


    public function month() {

        $date = Request::getParam('date', '');

        $_SESSION['day_pick'] = $date;  //设置选择日期的session，为了返回用

        $module_path = '/module/cinema_h5';


        Response::assign('module_path', $module_path);
        Response::assign('success', 0);

        if (!isset($_SESSION['user_id'])) {
            Response::redirect('cinema_h5');
            return false;
        }


        $date = date('Y-m-01');

        //当月
        $filter_day = array(
            'marketing_id' => $_SESSION['user_id'],
            '`receiver_time` >=' => $date,
            'status' => 1
        );
        $output['amount'] = _model('order')->getTotal($filter_day);
        if (!$output['amount']) {
            $output['amount'] = 0;
        }

        $output['money'] = _model('order')->getFields('price', $filter_day);
        if ($output['money']) {
            $output['money'] = array_sum($output['money']);
        } else {
            $output['money'] = 0;
        }

        echo json_encode($output);

    }


    public function season() {


        $module_path = '/module/cinema_h5';


        Response::assign('module_path', $module_path);
        Response::assign('success', 0);

        if (!isset($_SESSION['user_id'])) {
            Response::redirect('cinema_h5');
            return false;
        }

        $season = ceil((date('n')) / 3);//当月是第几季度
        $date = date('Y-m-d H:i:s', mktime(0, 0, 0, $season * 3 - 3 + 1, 1, date('Y')));

        //本季
        $filter_day = array(
            'marketing_id' => $_SESSION['user_id'],
            '`receiver_time` >' => $date,
            'status' => 1
        );
        $output['amount'] = _model('order')->getTotal($filter_day);
        if (!$output['amount']) {
            $output['amount'] = 0;
        }

        $output['money'] = _model('order')->getFields('price', $filter_day);
        if ($output['money']) {
            $output['money'] = array_sum($output['money']);
        } else {
            $output['money'] = 0;
        }

        $output['season'] = $season;

        echo json_encode($output);

    }


    public function myinfo() {

        $module_path = '/module/cinema_h5';


        Response::assign('module_path', $module_path);
        if (isset($_SESSION['user_id'])) {

            //临时写成sign_user_id 以后再改
            $user_info = _model('user')->getList(array('id' => $_SESSION['user_id']));
            if (empty($user_info)) {
                return '查无此人！';
            }
            $user_info = $user_info[0];
            Response::assign('user_info', $user_info);
            Response::display('myinfo.html');
        } else {
            Response::display('login.html');
        }
    }


    public function detail() {

        $module_path = '/module/cinema_h5';

        Response::assign('module_path', $module_path);

        $id = Request::Get('store_id', 1);

        if (isset($_SESSION['user_id'])) {

            $filter = array();
            $filter['id'] =  $id;

            $info = _model('store')->getList($filter);
            if ($info) {

                $info = $info[0];

            }else{
                return "查无此店！？";
            }

            if ($info['movie_type'] == '1') {
                $info['movie_type'] = '直营';
            } elseif ($info['movie_type'] == '2') {
                $info['movie_type'] = '加盟';
            } else {
                $info['movie_type'] = '私营';
            }

            if ($info['status'] == '0') {
                $info['status'] = '删除';
            } elseif ($info['status'] == '1') {
                $info['status'] = '试营业';
            } elseif ($info['status'] == '2') {
                $info['status'] = '正常';
            } else {
                $info['status'] = '暂停';
            }

            //签约人姓名电话
            $user_info = _model('user')->getList(array('id' => $_SESSION['user_id']));
            $user_info = $user_info[0];

            $info['sign_user_name']=$user_info['realname'];
            $info['sign_user_mobile']=$user_info['mobile'];

            //合伙人姓名电话
            $agency_info = _model('user')->getList(array('id' => $info['agency_id']));

            if(!$agency_info){
                $info['agency_name']='未录入';
                $info['agency_mobile']='未录入';
            }else{

                $agency_info = $agency_info[0];
                $info['agency_name']=$agency_info['realname'];
                $info['agency_mobile']=$agency_info['mobile'];
            }



            //店铺负责人姓名电话
            $owner_info = _model('user')->getList(array('id' => $info['owner_id']));
            if(!$owner_info){
                $info['owner_name']='未录入';
                $info['owner_mobile']='未录入';
            }else{
                $owner_info = $owner_info[0];
                $info['owner_name']=$owner_info['realname'];
                $info['owner_mobile']=$owner_info['mobile'];
            }


            // var_dump($info);
            Response::assign('info', $info);
            Response::display('detail.html');
        } else {
            Response::display('login.html');
        }
    }


    /**
     * 显示列表
     */
    public function lists() {
        $page = Request::Get('page_no', 1);

        $search = Request::Get('search', '');
        $info = null;

        $module_path = '/module/cinema_h5';
        Response::assign('module_path', $module_path);
        if (isset($_SESSION['user_id'])) {

            $filter = array();
            $filter['sign_user_id']= $_SESSION['user_id'];
            if(empty($search)!=1){
                $filter['title LIKE']= '%'.$search.'%';
            }

            $info = get_data_list('store',$filter , 'ORDER BY id DESC', $page, $this->per_page);
            // $store_count = _model('store')->getTotal(enable_filter($filter));


            foreach ($info as $k => $v) {
                //当月
                $filter = array(

                    '`store_id`'   => $v['id'],
                    '`receiver_time` >='         => date("Y-m-01", strtotime(date("Y-m-d")))
                );
                $amount= _model('order')->getFields('goods_num',$filter);
                $info[$k]['amount'] = array_sum($amount);



                $money = _model('order')->getFields('price', $filter);
                $info[$k]['money'] = array_sum($money);

                if ($v['is_delete'] == '1') {
                    $info[$k]['is_delete'] = '正常';
                } else{
                    $info[$k]['is_delete'] = '删除';
                }

                if ($v['status'] == '0') {
                    $info[$k]['status'] = '删除';
                } elseif ($v['status'] == '1') {
                    $info[$k]['status'] = '试营业';
                } elseif ($v['status'] == '2') {
                    $info[$k]['status']= '正常';
                } else {
                    $info[$k]['status'] = '暂停';
                }



                $info[$k]['sign_user_name'] = $_SESSION['user_name'];

                //合伙人姓名
                $agency_info= _model('user')->getFields('realname', array('`id`'=> $v['agency_id']));
                if(!$agency_info){
                    $info[$k]['agency_name']='未录入';
                }else{
                    $agency_info=$agency_info[0];
                    $info[$k]['agency_name']=$agency_info;
                }


            }

            $month = date('m'); //得到10

            Response::assign('month',$month);
            Response::assign('search',$search);
            Response::assign('info',$info);
            Response::display('lists.html');


        } else {
            Response::display('login.html');
        }
    }

    public function sign() {

        $module_path = '/module/cinema_h5';
        Response::assign('module_path', $module_path);

        if (isset($_SESSION['user_id']) && isset($_SESSION['user_name']) ) {

            Response::assign('user_id', $_SESSION['user_id'] );
            Response::assign('sign_user', $_SESSION['user_name'] );
            Response::display('sign.html');



        } else {
            Response::display('login.html');
        }


    }


    public function zzb_info() {

        $module_path = '/module/cinema_h5';
        Response::assign('module_path', $module_path);
        $zzb_code = Request::getParam('zzb_code', 1);//0能查到


        $zzb_info = _model('cinema_zzb')->getList(array('zzb_code'=> $zzb_code));
        if(empty($zzb_info)){
            echo json_encode($zzb_info);
        }
        else{
            $zzb_info = $zzb_info[0];
            echo json_encode($zzb_info);
        }

    }


    /**
     * ajax_get_provinces
     */
    public function ajax_get_provinces()
    {
        $filter = array();
        $filter['status'] = 1;
        $filter['depth'] = 1;
        $province_list = _model('region')->getList($filter);

        echo json_encode($province_list);
    }

    /**
     * ajax_get_citys
     */
    public function ajax_get_citys()
    {
        $province_code = Request::getParam('province_code');

        $filter = array();
        $filter['parent_id'] = $province_code;
        $filter['depth'] = 2;
        $filter['status'] = 1;

        $city_list = _model('region')->getList($filter);

        echo json_encode($city_list);
    }

    /**
     * ajax_get_countys
     */
    public function ajax_get_countys()
    {
        $city_code = Request::getParam('city_code', '');

        $county_filter = array();
        $county_filter['depth'] = 3;
        $county_filter['status'] = 1;
        $county_filter['parent_id'] = $city_code;

        $county_list = _model('region')->getList($county_filter);

        echo json_encode($county_list);
    }



    /**
     * 显示列表
     */
    public function outputDetail() {
        $page = Request::Get('page_no', 1);

        $search = Request::Get('search', '');
        $info = null;


        $module_path = '/module/cinema_h5';
        Response::assign('module_path', $module_path);
        if (isset($_SESSION['user_id'])) {

            $filter = array();
            $filter['sign_user_id']= $_SESSION['user_id'];
           // $filter['`store_order` <>']= 1;  

            $info = get_data_list('store',$filter , 'ORDER BY id DESC', $page, 20);
            // $store_count = _model('store')->getTotal(enable_filter($filter));

            //  var_dump($info); exit;

            foreach ($info as $k => $v) {
                //当月
                $filter = array(

                    '`store_id`'   => $v['id'],
                     '`receiver_time` >='         => date("Y-m-01", strtotime(date("Y-m-d")))
                );
                $amount= _model('order')->getTotal($filter);
                if (!$amount) {
                    $amount = 0;
                }
                $info[$k]['amount'] =$amount;      //门店订单笔数

                $money = _model('order')->getFields('price', $filter);
                $info[$k]['money'] = array_sum($money);


                //当季门店订单笔数
                $season = ceil((date('n')) / 3);//当月是第几季度
                $date = date('Y-m-d H:i:s', mktime(0, 0, 0, $season * 3 - 3 + 1, 1, date('Y')));
                $filter = array(

                    '`store_id`'   => $v['id'],
                    '`receiver_time` >='         => $date
                );
                $amount_season= _model('order')->getTotal($filter);
                if (!$amount_season) {
                    $amount_season = 0;
                }
                $info[$k]['amount_season'] =$amount_season;

                $money_season = _model('order')->getFields('price', $filter);
                $info[$k]['money_season'] = array_sum($money_season);


            }

            $month = date('m'); //得到10



            Response::assign('month',$month);
            Response::assign('search',$search);
            Response::assign('info',$info);
            Response::display('outputDetail.html');


        } else {
            Response::display('login.html');
        }
    }


    //查看负责人是否已经签约
    public function check_charger() {

        $module_path = '/module/cinema_h5';
        Response::assign('module_path', $module_path);
        $charger_mobile = Request::getParam('charger_mobile', 1);

        $charger_info = _model('user')->getList(array('mobile'=> $charger_mobile));
        if(empty($charger_info)){
            echo json_encode($charger_info);
        }
        else{
            $charger_info = $charger_info[0];
            echo json_encode($charger_info);
        }
    }


    /**
     * 签约门店
     */
    public function create_user_store() {

        if (!isset($_SESSION['user_id'])) {
            Response::redirect('/cinema_h5/login');
            return false;
        }

        $module_path = '/module/cinema_h5';
        Response::assign('module_path', $module_path);
        $message = '成功';
        $success = 0;

        $type        = Request::getParam('bm', 0);                      //门店类型
        $company     = Request::getParam('company', '');                //公司名称
        $cinema      = Request::getParam('cinema', '');                      //影院
        $circuit     = Request::getParam('circuit', '');                     //院线
        $province    = Request::getParam('province', '');                     //省份
        $city        = Request::getParam('city', '');                             //城市
        $district    = Request::getParam('district', '');                     //区县
        $address     = Request::getParam('address', '');                     //地址
        $user_id     = Request::getParam('user_id', 0);                     //签约人，就是登录用户
        $charger     = Request::getParam('charger', '');                     //负责人
        $charger_mobile = Request::getParam('charger_mobile', 0);        //负责人电话
        $mate_mobile = Request::getParam('mate_mobile', 0);            //合伙人电话
        $zzb_code    = Request::getParam('zzb_code', '');                 //专资编码
        $credit_code = Request::getParam('credit_code', 0);            //统一社会信用代码
        $store_branch = Request::getParam('store_branch', '');            //是否创建分店
        $is_allow_credit= Request::getParam('is_allow_credit', '');            //是否允许赊账

        if (!$charger_mobile) {
            $message =  '负责人手机号不能为空';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }

        if (!$company) {
            $message =  '开发票的公司名称不能为空';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }

        if (!$charger) {
            $message =  '负责人姓名不能为空';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }


        if (!$circuit) {
            $message =  '院线名称不能为空';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }

        if (!$address) {
            $message =  '门店地址不能为空';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }

        if (!$district) {
            $message =  '省市区不能为空';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }


        if($type == 1){
            $type = 100;//影院
            //先看地区编码能找到不
            if($district){
                $area_code = area_helper::get_area_code_by_area($district, 3);
                if(!$area_code){
                    $area_code = area_helper::get_area_code_by_area($city, 2);
                    if (!$area_code) {
                        $area_code = area_helper::get_area_code_by_area($province, 1);
                        if (!$area_code) {
                            $message =  '未找到此省份对应的地区编码';
                            Response::assign('success', $success);
                            Response::assign('message', $message);
                            Response::display('result.html');
                            return false;
                        }
                    }
                }

            }

            //验证专资编码
            $zzb_info = _model('cinema_zzb')->getList(array('zzb_code'=> $zzb_code));
            if(empty($zzb_info)){
                $message =  '专资编码不对';
                Response::assign('success', $success);
                Response::assign('message', $message);
                Response::display('result.html');
                return false;
            }

            $zzb = _model('store')->getList(array('zzb_id'=> $zzb_code));
            if(!empty($zzb)){
                $message =  '专资编码对应门店已经被签了';
                Response::assign('success', $success);
                Response::assign('message', $message);
                Response::display('result.html');
                return false;
            }

        }else{
            $type = 105;//私人影吧
            $area_code = $district;
        }


        if (in_array($type, store_config::$type_arr)) {
            $message =  '门店类型不对';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }

        if (!$cinema) {
            $message =  '门店名称不能为空';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }

        if (!$mate_mobile) {
            $message =  '合伙人手机号不能为空';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }

        //判断合伙人手机号是否存在
        $mate_user_info = user_helper::get_user_info_by_mobile($mate_mobile);
        if (!$mate_user_info) {
            $message =  '此手机号没查到合伙人信息';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;

        }

        $reg = '/^1[3|4|5|7|8]\d{9}$/';
        if (!preg_match($reg, $mate_mobile)) {
            $message =  '合伙人手机号格式错误';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }

        if (!preg_match($reg, $mate_mobile)) {
            $message =  '此手机号没查到合伙人信息';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }


        //判断影院市场专员
        $userinfo = user_helper::get_user_info(  $_SESSION['user_id']);
        if (!(user_config::CINEMA_ASSISTANT == $userinfo['role_type'])) {
            $message =  '您的身份不是影管专员';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        }

        //第一步：先上传图片
        $image = Request::Post('file0', '');    //门店对应的图片
        $image_data = Request::Post('image_data', '');

        $extname = pathinfo($image, PATHINFO_EXTENSION);
        if ($extname == 'jpeg') {
            $extname = 'jpg';
        }


        if (!$image || !$image_data ) {
            $message =  '请先上传图片';
            Response::assign('success', $success);
            Response::assign('message', $message);
            Response::display('result.html');
            return false;
        } else {

            $file_name = md5($image . datetime()) . '.' . $extname;

            // 图片上传
            file_put_contents('/tmp/' . $file_name, base64_decode($image_data));

            if (!ONDEV) {
                $file_path = aliysso_helper::sso_upload_file($file_name, '/tmp/' . $file_name);
            } else {
                $file_path = move_image($file_name);
            }

            if (!$file_path) {
                $message =  '门头图上传失败, 请稍后重试';
                Response::assign('success', $success);
                Response::assign('message', $message);
                Response::display('result.html');
                return false;
            }
        }

        //第二步：如果标志为1，表示已经创建过总店和分店，直接创建分店
        if($store_branch ==1){

            $charger_info = _model('user')->getList(array('mobile'=> $charger_mobile));
            if(!empty($charger_info)){

                $charger_info=$charger_info[0];

                //此情况是否可能存在？？？比如合伙人同时也是负责人;
        /*      $charger_user_info = _model('user_store')->getList(array('user_id'=> $charger_info['id']));
                if(!$charger_user_info){
                    $message =  '负责人手机已注册用户，但没签约总店';
                    Response::assign('success', $success);
                    Response::assign('message', $message);
                    Response::display('result.html');
                    return false;
                }*/
                $store_data = _widget('store')->create_store_new_tmp($_SESSION['user_id'],
                    $charger_info['id'], $charger_mobile,
                    $charger, $cinema, $cinema, $type, $area_code, $address, '', '',
                    $file_path, $userinfo,$mate_user_info['id'], $zzb_code, $credit_code,$company,$is_allow_credit);

                if (!$store_data[0]) {
                    $message =  '创建分店失败'.$store_data[1];
                    Response::assign('success', $success);
                    Response::assign('message', $message);
                    Response::display('result.html');
                    return false;
                }

            }else{
                $message =  '负责人手机号没查到用户信息';
                Response::assign('success', $success);
                Response::assign('message', $message);
                Response::display('result.html');
                return false;
            }
        }else{

             // 创建总店
             $user_store_data  = _widget('store')->create_new_user_store_tmp($userinfo, $charger, $charger_mobile, $cinema, $type, 0, 0, 0, 0,$mate_user_info['id'] );

             if (!$user_store_data[0]) {
                 $message =  '创建总店失败'.$user_store_data[1];
                 Response::assign('success', $success);
                 Response::assign('message', $message);
                 Response::display('result.html');
                 return false;

            } else {
                 // 创建分店
                 $store_data = _widget('store')->create_store_new_tmp($_SESSION['user_id'],
                     $user_store_data[1], $charger_mobile,
                     $charger, $cinema, $cinema, $type, $area_code, $address, '', '',
                     $file_path, $userinfo,$mate_user_info['id'], $zzb_code, 
                     $credit_code,$company,$is_allow_credit);

                 if (!$store_data[0]) {
                     $message =  '创建分店失败'.$store_data[1];
                     Response::assign('success', $success);
                     Response::assign('message', $message);
                     Response::display('result.html');
                     return false;
                 }

            }

        }


        $success = 1;
        $message = '签约成功，负责人：'.$charger.'；电话：'.$charger_mobile;


        Response::assign('success', $success);
        Response::assign('message', $message);
        Response::display('result.html');

    }
    
}


?>